package cut;

import jtg.visualizer.MyEnum;
import jtg.visualizer.Person;
import polyglot.ast.Do;

public class LogicStructure {

    public int sequence(int a, int b) {
        return a + b;
    }
    public boolean soloIfForMCDC(int op, int op2) {
        if (op < 0 || op > 10 && op2 < 18)
            return true;
        return false;
    }
    private int doubleNum(int n){
        return n*2;
    }
    public boolean soloIf(String op) {
        if (op.equals("123")) {
            return true;
        }
        return false;
    }
    public boolean soloIfDouble(String op) {
        if (Integer.valueOf(op) > 2.5)
        {
            return true;
        }

        return false;
    }

    public boolean ifElse(int op) {
        if (op > 18)
            return true;
        else
            return false;
    }

    public String multipleIf(int op) {
        if (op % 15 == 0)
            return "FizzBuzz";
        else if (op % 5 == 0)
            return "Buzz";
        else if (op % 3 == 0)
            return "Fizz";
        else
            return "1";
    }
    public int testMCDC(int a , int b){
        int temp = 2;
        if (a>8&&b>8)
            return 1;
        if (a<1&&b<1)
            return 2;
        if (a==temp||b==temp)
            return 0;
        return 3;
    }

    public int test1(int op) {
        int sum = 0;
            sum = op;

        return sum;
    }
    //测试string
    public int test2(String str) {
        if (str.length() < 10) {
            return 1;
        }else if (str.length() < 20){
            return 0;
        }else {
            return -1;
        }
    }


    //测试数组
    public int test3(int[] arr) {
        int sum = 0;
        for (int i = 0; i < arr.length; i++) {
            if (arr[i] > 0) {
                sum += arr[i];
            }else if (arr[i] == 0){
                sum -= arr[i];
            }else{
                sum ++;
            }
        }
        return sum;
    }

    //测试枚举类
    public int test4(MyEnum myEnum) {
        if (myEnum== MyEnum.a) {
            return -1;
        } else if (myEnum== MyEnum.b) {
            return 1;
        } else {
            return 0;
        }
    }

    //测试普通类
    public int test5(Person person) {
        int temp = person.getAge();
        if (person.getAge() > 0) {
            return test1(temp);
        }else {
            return test1(-temp);
        }
    }

    //测试函数调用
    public int test6(boolean op) {
        if (op ) {
            return test1(1);
        }else {
            return test1(2);
        }
    }

    //复杂类型的数组
    public int test7(Person[] people) {
        int sum = 0;
        for (int i = 0; i < people.length; i++) {
            Person person = people[i];
            if (person.getAge() > 0) {
                sum++;
            }else{
                sum--;
            }
        }
        return sum;
    }

    //复杂组合
    public int test8(int op, boolean flag, String chars, Person person) {
        if (flag&&op>1) {
            int a=2;
            int result=test1(a);
            return result;
        }else{
            int t = 4;
            int result = 0;
            if(chars.length()>4){
            while (t <=10) {
                t++;
                result += person.getAge();
            }}
            else {
                while (t>0){
                    t--;
                    result+=person.getAge();
                }
            }
            return result;
        }
    }


    public int test9(int  op,int b,int c) {
        int max;
        if (op>b){
            max=b;
        }
        else  max=op;
        if(c>max){
            max=c;
        }
        return max;
    }

    //测试枚举类

}
